'=======================================
' 执行所有测试 case
'=======================================
Private Sub test_ALL_Case()
    ' copyToNewArray 测试
    test_copyToNewArray
End Sub

'--------------------------------------------------------
' copyToNewArray 测试
'--------------------------------------------------------
Private Sub test_copyToNewArray()
    Dim tempRef As IPrimitiveArrayRef
    Dim baseRef As IPrimitiveArrayRef
    Set baseRef = UtilsArrayRef.createRealPrimitiveArrayRef
    baseRef.Add "c0"
    baseRef.Add "c1"
    baseRef.Add "c2"
    baseRef.Add "c3"
    baseRef.Add "c4"
    baseRef.Add "c5"
    baseRef.Add "c6"

    Dim tempSlice As PrimitiveArrayRefSlice
    Dim baseSlice As IPrimitiveArrayRef

    ' ------------------- 1. 空拷贝---------------------
    Set tempSlice = New PrimitiveArrayRefSlice
    tempSlice.Init baseRef, 1, 1, 2
    Set baseSlice = tempSlice

    Set tempRef = baseSlice.copyToNewArray
    Debug.Assert tempRef.Count = 0

    Set tempRef = baseSlice.copyToNewArray(1)
    Debug.Assert tempRef.Count = 0

    Set tempRef = baseSlice.copyToNewArray(endIdx := 2)
    Debug.Assert tempRef.Count = 0

    ' ------------------- 2. 边界测试---------------------
    Set tempSlice = New PrimitiveArrayRefSlice
    tempSlice.Init baseRef, 0, 10, 2
    Set baseSlice = tempSlice

    ' 1. 全部拷贝
    Set tempRef = baseSlice.copyToNewArray
    Debug.Assert tempRef.Count = 4
    Debug.Assert tempRef.Item(0) = "c0"
    Debug.Assert tempRef.Item(1) = "c2"
    Debug.Assert tempRef.Item(2) = "c4"
    Debug.Assert tempRef.Item(3) = "c6"

    ' 2. 结束索引边界
    Set tempRef = baseSlice.copyToNewArray(endIdx := 3)
    Debug.Assert tempRef.Count = 3
    Debug.Assert tempRef.Item(0) = "c0"
    Debug.Assert tempRef.Item(1) = "c2"
    Debug.Assert tempRef.Item(2) = "c4"

    Set tempRef = baseSlice.copyToNewArray(endIdx := 4)
    Debug.Assert tempRef.Count = 4
    Debug.Assert tempRef.Item(0) = "c0"
    Debug.Assert tempRef.Item(1) = "c2"
    Debug.Assert tempRef.Item(2) = "c4"
    Debug.Assert tempRef.Item(3) = "c6"

    ' 3. 起始 == 结束
    Set tempRef = baseSlice.copyToNewArray(1, 1)
    Debug.Assert tempRef.Count = 0

    ' 4. 起始 > 结束
    Set tempRef = baseSlice.copyToNewArray(2, 1)
    Debug.Assert tempRef.Count = 0

    ' 5. 起始 = 结束 - 1
    Set tempRef = baseSlice.copyToNewArray(1, 2)
    Debug.Assert tempRef.Count = 1
    Debug.Assert tempRef.Item(0) = "c2"
End Sub